package cn.com.haopy.dataes.es.service;

import cn.com.haopy.dataes.es.dto.CodeMatch;
import lombok.extern.log4j.Log4j;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 仓库药房和互联网医院云仓药房的关系
 * <p>
 */

@Service
@Slf4j
public class StoreCodeMatchCodeService {

    private List<CodeMatch> list = new ArrayList<>();

    public StoreCodeMatchCodeService() {
        CodeMatch codeMatch1 = new CodeMatch();
        codeMatch1.setWareHouse("WH01");
        codeMatch1.setHosCode("ST102458");
        codeMatch1.setHosName("五华昊邦医院门诊药房");

        list.add(codeMatch1);
    }


    public String getHosCode(String wareHouse) {
        try {
            for (int i = 0; i < list.size(); i++) {
                CodeMatch codeMatch = list.get(i);
                if (wareHouse.equals(codeMatch.getWareHouse())) {
                    return codeMatch.getHosCode();
                }
            }
        } catch (Exception e) {
            log.error(e.toString());
            return null;
        }

        return "";
    }


}
